#!/usr/bin/env python
# -*- encoding:utf-8 -*-
#**
#-------------------------------------------------------------------------------
#[Subject   -- SQL_Gen]
#[Author    -- tianxu.xxf]
#[Created   -- 2010.9.27]
#[Updated   -- ]
#[UpAuthor  -- ]
#-----------------------------------------------------------------------------*#
from Column import Column
from Condition import Condition
from Util.Parser import parseCondition
from Const._Column import ALL_COLUMN
from SQLException.TypeException import TypeException

def toColumn(column):
    if isinstance(column,str):
        if column is '*':
            return ALL_COLUMN
        else:
            return Column(column)
    elif isinstance(column,Column):
        return column
    else:
        raise TypeException
    

def toCondition(condition):
    if isinstance(condition,str):
        return parseCondition(condition)
    elif isinstance(condition,Condition):
        return condition
    else:
        raise TypeException
